// Glass with textured mask.
//
// Created by Zhiyong Yang, younthu@yahoo.com.cn
//
// The effects of this fragment shader is a transparent glass with texture mask.
// It is implemented with blend function of  GL ONE MINUS SRC ALPH, in another word, 
// we use mix fragment function.
uniform float time;
uniform float alpha; // Control the alpha of textured mask
uniform sampler2D glassMask;
uniform sampler2D tex;

void main()
{
	gl_FragColor = gl_Color * texture2D(tex,gl_TexCoord[0].xy);
    vec4 mask=texture2D(glassMask,gl_TexCoord[0].xy);
 
    gl_FragColor=mix(mask,gl_FragColor,alpha);
}
